type Flatten<T extends any[],U extends any[] = []> = 
    T extends []?U:T extends [infer First,...infer Rest]?First extends any[]?Flatten<[...First,...Rest],U>:
        Flatten<[...Rest],[...U,First]>:U


// type t = Flatten<[1, [2]]>